home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / QuickTime™ VR 2.0 SDK / Documentation + Extras / Updated Interfaces / QuickDraw 3D 1.5 Interfaces / Interfaces / QD3DGroup.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-22  |  14.5 KB  |  489 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DGroup.h                                                 **
  4.  **                                                                             **
  5.  **                                                                             **
  6.  **     Purpose:    Group definitions and routines                             **
  7.  **                                                                             **
  8.  **                                                                             **
  9.  **                                                                             **
  10.  **     Copyright (C) 1992-1996 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                             **
  12.  **                                                                             **
  13.  *****************************************************************************/
  14. #ifndef QD3DGroup_h
  15. #define QD3DGroup_h
  16.  
  17. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  18.     #pragma once
  19. #endif  /*  PRAGMA_ONCE  */
  20.  
  21. #if defined(THINK_C) || defined(__SC__)
  22.     #pragma options(!pack_enums, !align_arrays)
  23.     #pragma SC options align=power
  24. #elif defined(__MWERKS__)
  25.     #pragma enumsalwaysint on
  26.     #pragma align_array_members off
  27.     #pragma options align=native
  28. #elif defined(__PPCC__)
  29.     #pragma options align=power
  30. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  31.     #pragma options enum=int
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif /*  __cplusplus  */
  37.  
  38.  
  39. /******************************************************************************
  40.  **                                                                             **
  41.  **                            Group Typedefs                                     **
  42.  **                                                                             **
  43.  *****************************************************************************/
  44.  
  45. /*
  46.  *  These flags affect how a group is traversed
  47.  *  They apply to when a group is "drawn", "picked", "bounded", "written"
  48.  */
  49. typedef enum TQ3DisplayGroupStateMasks {
  50.     kQ3DisplayGroupStateNone                    = 0,
  51.     kQ3DisplayGroupStateMaskIsDrawn                = 1 << 0,
  52.     kQ3DisplayGroupStateMaskIsInline            = 1 << 1,
  53.     kQ3DisplayGroupStateMaskUseBoundingBox        = 1 << 2,
  54.     kQ3DisplayGroupStateMaskUseBoundingSphere    = 1 << 3,
  55.     kQ3DisplayGroupStateMaskIsPicked            = 1 << 4,
  56.     kQ3DisplayGroupStateMaskIsWritten            = 1 << 5
  57. } TQ3DisplayGroupStateMasks;
  58.  
  59. typedef unsigned long TQ3DisplayGroupState;
  60.  
  61.  
  62. /******************************************************************************
  63.  **                                                                             **
  64.  **                    Group Routines (apply to all groups)                     **
  65.  **                                                                             **
  66.  *****************************************************************************/
  67.  
  68. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3Group_New(        /* May contain any shared object */
  69.     void);
  70.     
  71. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3Group_GetType(
  72.     TQ3GroupObject            group);
  73.  
  74. QD3D_EXPORT TQ3GroupPosition QD3D_CALL Q3Group_AddObject(
  75.     TQ3GroupObject            group,
  76.     TQ3Object                object);
  77.     
  78. QD3D_EXPORT TQ3GroupPosition QD3D_CALL Q3Group_AddObjectBefore(
  79.     TQ3GroupObject            group,
  80.     TQ3GroupPosition        position,
  81.     TQ3Object                object);
  82.  
  83. QD3D_EXPORT TQ3GroupPosition QD3D_CALL Q3Group_AddObjectAfter(
  84.     TQ3GroupObject            group,
  85.     TQ3GroupPosition        position,
  86.     TQ3Object                object);
  87.  
  88. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetPositionObject(
  89.     TQ3GroupObject            group,
  90.     TQ3GroupPosition        position,    
  91.     TQ3Object                *object);        
  92.  
  93. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_SetPositionObject(
  94.     TQ3GroupObject            group,
  95.     TQ3GroupPosition        position,
  96.     TQ3Object                object);
  97.  
  98. QD3D_EXPORT TQ3Object QD3D_CALL Q3Group_RemovePosition(
  99.     TQ3GroupObject            group,
  100.     TQ3GroupPosition        position);
  101.  
  102. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetFirstPosition(        
  103.     TQ3GroupObject            group,
  104.     TQ3GroupPosition        *position);
  105.  
  106. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetLastPosition(        
  107.     TQ3GroupObject            group,
  108.     TQ3GroupPosition        *position);
  109.  
  110. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetNextPosition(        
  111.     TQ3GroupObject            group,
  112.     TQ3GroupPosition        *position);
  113.  
  114. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetPreviousPosition(        
  115.     TQ3GroupObject            group,
  116.     TQ3GroupPosition        *position);
  117.  
  118. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_CountObjects(
  119.     TQ3GroupObject            group,
  120.     unsigned long            *nObjects);
  121.  
  122. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_EmptyObjects(
  123.     TQ3GroupObject            group);
  124.     
  125. /*
  126.  *     Typed Access
  127.  */
  128. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetFirstPositionOfType(        
  129.     TQ3GroupObject            group,
  130.     TQ3ObjectType            isType,
  131.     TQ3GroupPosition        *position);
  132.  
  133. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetLastPositionOfType(        
  134.     TQ3GroupObject            group,
  135.     TQ3ObjectType            isType,
  136.     TQ3GroupPosition        *position);
  137.  
  138. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetNextPositionOfType(        
  139.     TQ3GroupObject            group,
  140.     TQ3ObjectType            isType,
  141.     TQ3GroupPosition        *position);
  142.  
  143. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetPreviousPositionOfType(        
  144.     TQ3GroupObject            group,
  145.     TQ3ObjectType            isType,
  146.     TQ3GroupPosition        *position);
  147.  
  148. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_CountObjectsOfType(
  149.     TQ3GroupObject            group,
  150.     TQ3ObjectType            isType,
  151.     unsigned long            *nObjects);
  152.  
  153. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_EmptyObjectsOfType(
  154.     TQ3GroupObject            group,
  155.     TQ3ObjectType            isType);
  156.  
  157. /*
  158.  *    Determine position of objects in a group
  159.  */
  160. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetFirstObjectPosition(
  161.     TQ3GroupObject            group,
  162.     TQ3Object                object,
  163.     TQ3GroupPosition        *position);
  164.     
  165. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetLastObjectPosition(
  166.     TQ3GroupObject            group,
  167.     TQ3Object                object,
  168.     TQ3GroupPosition        *position);
  169.  
  170. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetNextObjectPosition(
  171.     TQ3GroupObject            group,
  172.     TQ3Object                object,
  173.     TQ3GroupPosition        *position);
  174.     
  175. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetPreviousObjectPosition(
  176.     TQ3GroupObject            group,
  177.     TQ3Object                object,
  178.     TQ3GroupPosition        *position);
  179.     
  180.  
  181. /******************************************************************************
  182.  **                                                                             **
  183.  **                            Group Subclasses                                 **
  184.  **                                                                             **
  185.  *****************************************************************************/
  186.  
  187. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3LightGroup_New(    /* Must contain only lights */
  188.     void);
  189.  
  190. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3InfoGroup_New(        /* Must contain only strings */
  191.     void);
  192.  
  193.  
  194. /******************************************************************************
  195.  **                                                                             **
  196.  **                        Display Group Routines                                 **
  197.  **                                                                             **
  198.  *****************************************************************************/
  199.  
  200. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3DisplayGroup_New(    /* May contain only drawables*/
  201.     void);
  202.     
  203. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3DisplayGroup_GetType(
  204.     TQ3GroupObject            group);
  205.  
  206. QD3D_EXPORT TQ3Status QD3D_CALL Q3DisplayGroup_GetState(
  207.     TQ3GroupObject            group,
  208.     TQ3DisplayGroupState    *state);
  209.     
  210. QD3D_EXPORT TQ3Status QD3D_CALL Q3DisplayGroup_SetState(
  211.     TQ3GroupObject            group,
  212.     TQ3DisplayGroupState    state);
  213.  
  214. QD3D_EXPORT TQ3Status QD3D_CALL Q3DisplayGroup_Submit(
  215.     TQ3GroupObject            group, 
  216.     TQ3ViewObject            view);
  217.  
  218.  
  219. /*
  220.  *
  221.  *    Ordered Display Group
  222.  *
  223.  *    Ordered display groups keep objects in order by the type of object:
  224.  *
  225.  *    1    kQ3ShapeTypeTransform
  226.  *    2    kQ3ShapeTypeStyle
  227.  *    3    kQ3SetTypeAttribute
  228.  *    4    kQ3ShapeTypeShader
  229.  *    5    kQ3ShapeTypeCamera
  230.  *    6    kQ3ShapeTypeLight
  231.  *    7    kQ3ShapeTypeGeometry
  232.  *    8    kQ3ShapeTypeGroup            
  233.  *    9    kQ3ShapeTypeUnknown
  234.  *
  235.  *    Within a type, you are responsible for keeping things in order.
  236.  *
  237.  *    You may access and/or manipulate the group using the above types
  238.  *    (fast), or you may use any parent or leaf class types (slower).
  239.  *
  240.  *    Additional types will be added as functionality grows.
  241.  *
  242.  *    The group calls which access by type are much faster for ordered 
  243.  *    display group for the types above.*
  244.  *
  245.  *  N.B. In QuickDraw 3D 1.0 Lights and Cameras are a no-op when drawn
  246.  *
  247.  */
  248.  
  249. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3OrderedDisplayGroup_New(
  250.     void);
  251.  
  252. /*
  253.  *
  254.  *    IO Proxy Display Group
  255.  *
  256.  *    IO Proxy display groups are used to place more than one
  257.  *    representation of an object in a metafile. For example, if you know
  258.  *    another program does not understand NURBPatches but does understand
  259.  *    Meshes, you may place a mesh and a NURB Patch in an IO Proxy Group,
  260.  *    and the reading program will select the desired representation.
  261.  *
  262.  *    Objects in an IO Proxy Display Group are placed in their preferred
  263.  *    order, with the FIRST object being the MOST preferred, the LAST
  264.  *    object the least preferred.
  265.  *
  266.  *    The behavior of an IO Proxy Display Group is that when drawn/picked/
  267.  *    bounded, the first object in the group that is not "Unknown" is used,
  268.  *    and the other objects ignored.
  269.  *
  270.  */
  271.  
  272. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3IOProxyDisplayGroup_New(
  273.     void);
  274.  
  275. /******************************************************************************
  276.  **                                                                             **
  277.  **                        Group Extension Definitions                             **
  278.  **                                                                             **
  279.  *****************************************************************************/
  280. /*
  281.  *    Searching methods - OPTIONAL
  282.  */
  283. #define kQ3XMethodType_GroupAcceptObject                \
  284.     Q3_METHOD_TYPE('g','a','c','o')
  285. typedef TQ3Boolean (QD3D_CALLBACK *TQ3XGroupAcceptObjectMethod)(
  286.     TQ3GroupObject        group,
  287.     TQ3Object            object);
  288.  
  289. #define kQ3XMethodType_GroupAddObject                    \
  290.     Q3_METHOD_TYPE('g','a','d','o')
  291. typedef TQ3GroupPosition (QD3D_CALLBACK *TQ3XGroupAddObjectMethod)(
  292.     TQ3GroupObject        group,
  293.     TQ3Object            object);
  294.  
  295. #define kQ3XMethodType_GroupAddObjectBefore                \
  296.     Q3_METHOD_TYPE('g','a','o','b')
  297. typedef TQ3GroupPosition (QD3D_CALLBACK *TQ3XGroupAddObjectBeforeMethod)(
  298.     TQ3GroupObject        group,
  299.     TQ3GroupPosition    position,
  300.     TQ3Object            object);
  301.  
  302. #define kQ3XMethodType_GroupAddObjectAfter                \
  303.     Q3_METHOD_TYPE('g','a','o','a')
  304. typedef TQ3GroupPosition (QD3D_CALLBACK *TQ3XGroupAddObjectAfterMethod)(
  305.     TQ3GroupObject        group,
  306.     TQ3GroupPosition    position,
  307.     TQ3Object            object);
  308.  
  309. #define kQ3XMethodType_GroupSetPositionObject             \
  310.     Q3_METHOD_TYPE('g','s','p','o')
  311. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupSetPositionObjectMethod)(
  312.     TQ3GroupObject        group,
  313.     TQ3GroupPosition    gPos,
  314.     TQ3Object            obj);
  315.  
  316. #define kQ3XMethodType_GroupRemovePosition                \
  317.     Q3_METHOD_TYPE('g','r','m','p')
  318. typedef TQ3Object (QD3D_CALLBACK *TQ3XGroupRemovePositionMethod)(
  319.     TQ3GroupObject        group,
  320.     TQ3GroupPosition    position);
  321.  
  322. /*
  323.  *    Searching methods - OPTIONAL - default uses above methods
  324.  */
  325. #define kQ3XMethodType_GroupGetFirstPositionOfType         \
  326.     Q3_METHOD_TYPE('g','f','r','t')
  327. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetFirstPositionOfTypeMethod)(
  328.     TQ3GroupObject        group,
  329.     TQ3ObjectType        isType,
  330.     TQ3GroupPosition    *gPos);
  331.  
  332. #define kQ3XMethodType_GroupGetLastPositionOfType        \
  333.     Q3_METHOD_TYPE('g','l','s','t')
  334. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetLastPositionOfTypeMethod)(
  335.     TQ3GroupObject        group,
  336.     TQ3ObjectType        isType,
  337.     TQ3GroupPosition    *gPos);
  338.  
  339. #define kQ3XMethodType_GroupGetNextPositionOfType        \
  340.     Q3_METHOD_TYPE('g','n','x','t')
  341. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetNextPositionOfTypeMethod)(
  342.     TQ3GroupObject        group,
  343.     TQ3ObjectType        isType,
  344.     TQ3GroupPosition    *gPos);
  345.  
  346. #define kQ3XMethodType_GroupGetPrevPositionOfType        \
  347.     Q3_METHOD_TYPE('g','p','v','t')
  348. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetPrevPositionOfTypeMethod)(
  349.     TQ3GroupObject        group,
  350.     TQ3ObjectType        isType,
  351.     TQ3GroupPosition    *gPos);
  352.  
  353. #define kQ3XMethodType_GroupCountObjectsOfType            \
  354.     Q3_METHOD_TYPE('g','c','n','t')
  355. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupCountObjectsOfTypeMethod)(
  356.     TQ3GroupObject        group,
  357.     TQ3ObjectType        isType,
  358.     unsigned long        *nObjects);
  359.  
  360. #define kQ3XMethodType_GroupEmptyObjectsOfType            \
  361.     Q3_METHOD_TYPE('g','e','o','t')
  362. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupEmptyObjectsOfTypeMethod)(
  363.     TQ3GroupObject        group,
  364.     TQ3ObjectType        isType);
  365.  
  366. #define kQ3XMethodType_GroupGetFirstObjectPosition        \
  367.     Q3_METHOD_TYPE('g','f','o','p')
  368. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetFirstObjectPositionMethod)(
  369.     TQ3GroupObject        group,
  370.     TQ3Object            object,
  371.     TQ3GroupPosition    *gPos);
  372.  
  373. #define kQ3XMethodType_GroupGetLastObjectPosition        \
  374.     Q3_METHOD_TYPE('g','l','o','p')
  375. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetLastObjectPositionMethod)(
  376.     TQ3GroupObject        group,
  377.     TQ3Object            object,
  378.     TQ3GroupPosition    *gPos);
  379.  
  380. #define kQ3XMethodType_GroupGetNextObjectPosition        \
  381.     Q3_METHOD_TYPE('g','n','o','p')
  382. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetNextObjectPositionMethod)(
  383.     TQ3GroupObject        group,
  384.     TQ3Object            object,
  385.     TQ3GroupPosition    *gPos);
  386.  
  387. #define kQ3XMethodType_GroupGetPrevObjectPosition        \
  388.     Q3_METHOD_TYPE('g','p','o','p')
  389. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetPrevObjectPositionMethod)(
  390.     TQ3GroupObject        group,
  391.     TQ3Object            object,
  392.     TQ3GroupPosition    *gPos);
  393.  
  394. /*
  395.  *    Group Position Methods
  396.  *    
  397.  */
  398. #define kQ3XMethodType_GroupPositionSize            \
  399.     Q3_METHOD_TYPE('g','g','p','z')
  400. typedef unsigned long TQ3XMethodTypeGroupPositionSize;
  401.  
  402. #define kQ3XMethodType_GroupPositionNew                \
  403.     Q3_METHOD_TYPE('g','g','p','n')
  404. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupPositionNewMethod)(
  405.     void                    *gPos,
  406.     TQ3Object                object,
  407.     const void                *initData);
  408.  
  409. #define kQ3XMethodType_GroupPositionCopy            \
  410.     Q3_METHOD_TYPE('g','g','p','c')
  411. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupPositionCopyMethod)(
  412.     void                    *srcGPos,
  413.     void                    *dstGPos);
  414.  
  415. #define kQ3XMethodType_GroupPositionDelete            \
  416.     Q3_METHOD_TYPE('g','g','p','d')
  417. typedef void (QD3D_CALLBACK *TQ3XGroupPositionDeleteMethod)(
  418.     void                    *gPos);
  419.  
  420. /*
  421.  *    View Drawing Helpers
  422.  *    
  423.  *    TQ3XGroupStartIterateMethod
  424.  *
  425.  *        Pass back *object = NULL to NOT call EndIterate iterate
  426.  *        Pass back *object != NULL to draw object
  427.  *         (other side will pass it to EndIterate for deletion!)
  428.  *
  429.  *        *iterator is uninitialized, use for iteration state. Caller should 
  430.  *         ignore it.
  431.  *    
  432.  *    TQ3XGroupEndIterateMethod
  433.  *    
  434.  *        *object is previous object, dispose it or play with it.
  435.  *        Pass back NULL when last iteration has occurred
  436.  *        *iterator is previous value, use for iteration state Caller should 
  437.  *        ignore it.
  438.  */
  439. #define kQ3XMethodType_GroupStartIterate            \
  440.     Q3_METHOD_TYPE('g','s','t','d')
  441. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupStartIterateMethod)(
  442.     TQ3GroupObject        group,
  443.     TQ3GroupPosition    *iterator,
  444.     TQ3Object             *object,
  445.     TQ3ViewObject        view);
  446.  
  447. #define kQ3XMethodType_GroupEndIterate                \
  448.     Q3_METHOD_TYPE('g','i','t','d')
  449. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupEndIterateMethod)(
  450.     TQ3GroupObject        group,
  451.     TQ3GroupPosition    *iterator,
  452.     TQ3Object             *object,
  453.     TQ3ViewObject        view);
  454.  
  455. /*
  456.  *    IO  Helpers
  457.  *    
  458.  *    TQ3XGroupEndReadMethod
  459.  *        Called when a group has been completely read. Group should perform
  460.  *        validation and clean up any reading caches.
  461.  */
  462. #define kQ3XMethodType_GroupEndRead                    \
  463.     Q3_METHOD_TYPE('g','e','r','d')
  464. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupEndReadMethod)(
  465.     TQ3GroupObject        group);
  466.  
  467.  
  468. QD3D_EXPORT void *QD3D_CALL Q3XGroup_GetPositionPrivate(
  469.     TQ3GroupObject            group,
  470.     TQ3GroupPosition        position);
  471.     
  472. #ifdef __cplusplus
  473. }
  474. #endif /*  __cplusplus  */
  475.  
  476. #if defined(THINK_C) || defined(__SC__)
  477.     #pragma SC options align=reset
  478. #elif defined(__MWERKS__)
  479.     #pragma enumsalwaysint reset
  480.     #pragma align_array_members reset
  481.     #pragma options align=reset
  482. #elif  defined(__PPCC__)
  483.     #pragma options align=reset
  484. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  485.     #pragma options enum=reset
  486. #endif
  487.  
  488. #endif /*  QD3DGroup_h  */
  489.